package mail_remote_control;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;

/**
 *
 * @author Krzysztof Lech (Stiopa)
 */
public class Config {

    private String filename;

    Config(String conffile) {
           filename = conffile;
    }

    public void loadProperties(){
        File f = new File(filename);
        System.setProperty("file.encoding", "UTF-8");
        //Strumień wejściowy
        InputStream is;
        try {
            is = new FileInputStream(f);
            //ładujemy nasze ustawienia
            properties.load(is);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
   }

   public void saveProperties(String value){
        File f = new File(filename);
        OutputStream os;
        try {
            os = new FileOutputStream(f);
            properties.setProperty("mail", value);
            properties.store(os, null);
        } catch (FileNotFoundException e) {
                e.printStackTrace();
        } catch (IOException e) {
                e.printStackTrace();
        }
   }
   
   public Properties properties = new Properties();
}